﻿Imports System.Data.SqlClient

Public Class WebForm3
    Inherits System.Web.UI.Page
    'Dim connectionString As String = "Data Source=SHANK-PC\SQLEXPRESS;Initial Catalog=WinterPark;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False"
    'Dim connectionString As String = "Data Source=(localdb)\Projects;Initial Catalog=CIS441WinterParkWeb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False"
    Dim con As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("MainConn").ConnectionString)

    Public UName As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim Cust As String = "1"
        Dim Employee As String = "2"
        Dim Admin As String = "3"
        'Dim LoginStatement As String = "SELECT * FROM Login"
        'Dim LoginDataAdapter As New SqlDataAdapter(LoginStatement, con)
        'Dim LoginDataSet As New DataSet
        'LoginDataAdapter.Fill(LoginDataSet, "Login")
        Dim LoginStatement As String = "SELECT * FROM Login where UserName='" & UName & "' "
        Dim LoginCmd As New SqlCommand(LoginStatement, con)
        con.Open()
        Dim LoginReader As SqlDataReader
        LoginReader = LoginCmd.ExecuteReader
        If LoginReader.Read Then
            If LoginReader.Item("SecurityID") = Cust Then
                MaintButton.Visible = False
                SearchButton.Visible = True
                RegistrationButton.Visible = True
                ReportsButton.Visible = False
            ElseIf LoginReader.Item("SecurityID") = Employee Then
                MaintButton.Visible = False
                SearchButton.Visible = True
                RegistrationButton.Visible = True
                ReportsButton.Visible = False
            ElseIf LoginReader.Item("SecurityID") = Admin Then
                MaintButton.Visible = True
                SearchButton.Visible = True
                RegistrationButton.Visible = True
                ReportsButton.Visible = True
            End If
            End If
        '  Dim dr As DataRow
        ' For Each dr In LoginDataSet.Tables("Login").Rows
        'If dr.Item("UserName") = UName And dr.Item("SecurityID") = Cust Then
        'MaintButton.Visible = False
        'SearchButton.Visible = True)
        'RegistrationButton.Visible = True
        'ReportsButton.Visible = False
        'ElseIf dr.Item("UserName") = UName And dr.Item("SecurityID") = Employee Then
        'MaintButton.Visible = False
        'SearchButton.Visible = True
        'RegistrationButton.Visible = True
        'ReportsButton.Visible = False
        'ElseIf dr.Item("UserName") And dr.Item("SecurityID") = Admin Then
        'MaintButton.Visible = True
        'SearchButton.Visible = True
        'RegistrationButton.Visible = True
        'ReportsButton.Visible = True
        'End If
        'Next dr


    End Sub
    Protected Sub LockerButton_Click(sender As Object, e As EventArgs) Handles LockerButton.Click
        Server.Transfer("SeasonLocker.aspx")
    End Sub

    Protected Sub PassButton_Click(sender As Object, e As EventArgs) Handles PassButton.Click
        Server.Transfer("SeasonMembership.aspx")
    End Sub

    Protected Sub LessonButton_Click(sender As Object, e As EventArgs) Handles LessonButton.Click
        Server.Transfer("Lesson.aspx")
    End Sub

    Protected Sub MaintButton_Click(sender As Object, e As EventArgs) Handles MaintButton.Click
        Server.Transfer("Maintenance.aspx")
    End Sub

    Protected Sub LogoutButton_Click(sender As Object, e As EventArgs) Handles LogoutButton.Click
        Server.Transfer("Login.aspx")
    End Sub

    Private Sub ReportsButton_Click(sender As Object, e As EventArgs) Handles ReportsButton.Click
        Server.Transfer("Reports.aspx")
    End Sub

    Private Sub RegistrationButton_Click(sender As Object, e As EventArgs) Handles RegistrationButton.Click
        Server.Transfer("Registration.aspx")
    End Sub
End Class